'\" te
.\" Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH CT_TMPL_ACTIVATE 3CONTRACT "Apr 1, 2004"
.SH NAME
ct_tmpl_activate, ct_tmpl_clear, ct_tmpl_create, ct_tmpl_set_cookie,
ct_tmpl_set_critical, ct_tmpl_set_informative, ct_tmpl_get_cookie,
ct_tmpl_get_critical, ct_tmpl_get_informative \- common contract template
functions
.SH SYNOPSIS
.LP
.nf
cc [ \fIflag\fR\&.\|.\|. ] \fIfile\fR\&.\|.\|. \fB-D_LARGEFILE64_SOURCE\fR \fB -lcontract \fR [ \fIlibrary\fR\&.\|.\|. ]
#include <libcontract.h>

\fBint\fR \fBct_tmpl_activate\fR(\fBint\fR \fIfd\fR);
.fi

.LP
.nf
\fBint\fR \fBct_tmpl_clear\fR(\fBint\fR \fIfd\fR);
.fi

.LP
.nf
\fBint\fR \fBct_tmpl_create\fR(\fBint\fR \fIfd\fR, \fBctid_t *\fR\fIidp\fR);
.fi

.LP
.nf
\fBint\fR \fBct_tmpl_set_cookie\fR(\fBint\fR \fIfd\fR, \fBuint64_t\fR \fIcookie\fR);
.fi

.LP
.nf
\fBint\fR \fBct_tmpl_set_critical\fR(\fBint\fR \fIfd\fR, \fBuint_t\fR \fIevents\fR);
.fi

.LP
.nf
\fBint\fR \fBct_tmpl_set_informative\fR(\fBint\fR \fIfd\fR, \fBuint_t\fR \fIevents\fR);
.fi

.LP
.nf
\fBint\fR \fBct_tmpl_get_cookie\fR(\fBint\fR \fIfd\fR, \fBuint64_t *\fR\fIcookiep\fR);
.fi

.LP
.nf
\fBint\fR \fBct_tmpl_get_critical\fR(\fBint\fR \fIfd\fR, \fBuint_t *\fR\fIeventsp\fR);
.fi

.LP
.nf
\fBint\fR \fBct_tmpl_get_informative\fR(\fBint\fR \fIfd\fR, \fBuint_t *\fR\fIeventsp\fR);
.fi

.SH DESCRIPTION
.sp
.LP
These functions operate on contract template file descriptors obtained from the
\fBcontract\fR(5) file system.
.sp
.LP
The \fBct_tmpl_activate()\fR function makes the template referenced by the file
descriptor \fIfd\fR the active template for the calling thread.
.sp
.LP
The \fBct_tmpl_clear()\fR function clears calling thread's active template.
.sp
.LP
The \fBct_tmpl_create()\fR function uses the template referenced by the file
descriptor \fIfd\fR to create a new contract. If successful, the ID of the
newly created contract is placed in *\fIidp\fR.
.sp
.LP
The \fBct_tmpl_set_cookie()\fR and \fBct_tmpl_get_cookie()\fR functions write
and read the cookie term of a contract template. The cookie term is ignored by
the system, except to include its value in a resulting contract's status
object. The default cookie term is 0.
.sp
.LP
The \fBct_tmpl_set_critical()\fR and \fBct_tmpl_get_critical()\fR functions
write and read the critical event set term. The value is a collection of bits
as described in the contract type's manual page.
.sp
.LP
The \fBct_tmpl_set_informative()\fR and \fBct_tmpl_get_informative()\fR
functions write and read the informative event set term. The value is a
collection of bits as described in the contract type's manual page.
.SH RETURN VALUES
.sp
.LP
Upon successful completion, \fBct_tmpl_activate()\fR, \fBct_tmpl_create()\fR,
\fBct_tmpl_set_cookie()\fR, \fBct_tmpl_get_cookie()\fR,
\fBct_tmpl_set_critical()\fR, \fBct_tmpl_get_critical()\fR,
\fBct_tmpl_set_informative()\fR, and \fBct_tmpl_get_informative()\fR return 0.
Otherwise, they return a non-zero error value.
.SH ERRORS
.sp
.LP
The \fBct_tmpl_create()\fR function will fail if:
.sp
.ne 2
.na
\fB\fBERANGE\fR\fR
.ad
.RS 10n
The terms specified in the template were unsatisfied at the time of the call.
.RE

.sp
.ne 2
.na
\fB\fBEAGAIN\fR\fR
.ad
.RS 10n
The \fIproject\fR.\fImax-contracts\fR resource control would have been
exceeded.
.RE

.sp
.LP
The \fBct_tmpl_set_critical()\fR and \fBct_tmpl_set_informative()\fR functions
will fail if:
.sp
.ne 2
.na
\fB\fBEINVAL\fR\fR
.ad
.RS 10n
An invalid event was specified.
.RE

.sp
.LP
The \fBct_tmpl_set_critical()\fR function will fail if:
.sp
.ne 2
.na
\fB\fBEPERM\fR\fR
.ad
.RS 9n
One of the specified events was disallowed given other contract terms (see
\fBcontract\fR(5)) and {\fBPRIV_CONTRACT_EVENT\fR} was not in the effective set
for the calling process.
.RE

.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
Interface Stability	Evolving
_
MT-Level	Safe
.TE

.SH SEE ALSO
.sp
.LP
.BR libcontract (3LIB),
.BR contract (5),
.BR attributes (7),
.BR lfcompile (7)
